package net.diaowen.common.utils;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;

@SuppressWarnings("serial")
@Data
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class ResponseResult<T> implements Serializable {

    /**
     * 成功码.
     */
    public static final String SUCCESS_CODE = "200";

    /**
     * 成功信息.
     */
    public static final String SUCCESS_MESSAGE = "操作成功";

    // 操作是否成功
    private boolean flag;
    // 请求返回的状态码
    private String code;
    // 请求返回的信息说明
    private String message;
    // 请求返回的数据
    private T result;


    public void success(T result) {
        this.flag = true;
        this.code = SUCCESS_CODE;
        this.message = SUCCESS_MESSAGE;
        this.result = result;
    }

}
